/*
 * @(#) $Header$
 *
 * Copyright (C) 2010  Daniel Léonard
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package ca.forklabs.crypto.spec;

import java.security.spec.AlgorithmParameterSpec;

/**
 * This class encapsulates parameters for the SNEFRU message digest. SNEFRU
 * message digests only have two possible lengths: 128 and 256 bits. They
 * also can have from 2 to 8 passes, altought the 2 passes version has been
 * broken and rumors goes that the 4 passes version also has been broken. The
 * author of SNEFRU recommends 8 passes.
 *
 * @author   <a href="forklabs at gmail.com?subject=ca.forklabs.crypto.spec.SNEFRUspec">Daniel Léonard</a>
 * @version $Revision$
 * @see   ca.forklabs.crypto.md.SNEFRU
 */
public class SNEFRUspec implements AlgorithmParameterSpec {

//---------------------------
// Instance variables
//---------------------------

   /** The number of passes. */
   private int passes;

   /** The length in bits of the digest. */
   private int length;


//---------------------------
// Constructor
//---------------------------

   /**
    * Constructs and initializes a <code>SNEFRUspec</code> with 8 passes and a
    * digest length of 128 bits.
    */
   public SNEFRUspec() {
      this(8, 128);
      }

   /**
    * Constructs and initializes a <code>SNEFRUspec</code> with the specified
    * parameters.
    * @param   passes   number of passes (between 2 and 8).
    * @param   length   the length of the message digest (128 or 256 bits).
    */
   public SNEFRUspec(int passes, int length) {
      this.setPasses(passes);
      this.setLength(length);
      }


//---------------------------
// Accessors and mutators
//---------------------------

   /**
    * Gets the length of the SNEFRU message digest.
    * @return   the length of the message digest in bits.
    */
   public int getLength() {
      return this.length;
      }

   /**
    * Changes the bit-length of the digest.
    * @param   length   the new bit-length.
    */
   public void setLength(int length) {
      this.length = length;
      }

   /**
    * Gets the number of passes of the SNEFRU message digest.
    * @return   the number of passes of the message digest.
    */
   public int getPasses() {
      return this.passes;
      }

   /**
    * Changes the number of passes.
    * @param   passes   the new number of passes.
    */
   public void setPasses(int passes) {
      this.passes = passes;
      }

   }

